public class Bullet implements Runnable{
    private int x, y, dir;

    public boolean isLeft() {
        return left;
    }

    public void setLeft(boolean left) {
        this.left = left;
    }

    private boolean left = true;
    Bullet(int x, int y, int dir){
        this.x = x;
        this.y = y;
        this.dir = dir;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }

    public int getY() {
        return y;
    }

    public void setY(int y) {
        this.y = y;
    }

    public int getDir() {
        return dir;
    }

    public void setDir(int dir) {
        this.dir = dir;
    }

    public int getSpeed() {
        return speed;
    }

    public void setSpeed(int speed) {
        this.speed = speed;
    }
    private int speed = 15;

    @Override
    public void run() {
        while(true){
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            switch (this.getDir()){
                case 0:
                    this.setY(this.getY() + this.getSpeed());
                    break;
                case 1:
                    this.setY(this.getY() - this.getSpeed());
                    break;
                case 2:
                    this.setX(this.getX() + this.getSpeed());
                    break;
                case 3:
                    this.setX(this.getX() - this.getSpeed());
                    break;
            }
        }
    }
}
